<template>
  <div class="tongji">
    <div class="btn">
      <el-button type="primary" @click="tongjiss">各奖项数量统计</el-button>
      <el-button type="primary" @click="chuangxindanwei">创新奖单位</el-button>
      <el-button type="primary" @click="chuangxingeren">创新奖个人</el-button>
      <el-button type="primary" @click="cujindanwei">促进奖单位</el-button>
      <el-button type="primary" @click="cujingeren">促进奖个人</el-button>
      <el-button type="primary" @click="gongjiang">工匠精神奖</el-button>
      <el-button type="primary" @click="chengguo">创新成果奖</el-button>
      <!-- <el-button type="primary" @click="heji">成果奖全部</el-button> -->
    </div>
    <div class="tables">
      <template>
        <el-table :data="tableData" style="width: 100%">
          <el-table-column prop="indexs" label="序号"></el-table-column>
          <el-table-column prop="award_name" label="奖项名称"></el-table-column>
          <el-table-column prop="count" label="申报数量"></el-table-column>
          <el-table-column prop="yitijiao" label="已提交"></el-table-column>

          <el-table-column prop="weitijiao" label="未提交"></el-table-column>
          <el-table-column prop="weishenhe" label="未审核"></el-table-column>
          <el-table-column prop="yitongguo" label="审核通过"></el-table-column>
          <el-table-column
            prop="weitongguo"
            label="审核不通过"
          ></el-table-column>
        </el-table>
      </template>
    </div>
  </div>
</template>

<script>
import { statistics } from "../axios/api";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  created() {
    this.statistics();
  },
  components: {},

  methods: {
    tongjiss() {
      window.location.href =
        "https://" + window.location.host + "/common/award_export?type=1";
    },
    cujindanwei() {
      window.location.href =
        "https://" + window.location.host + "/common/award_export?type=4";
    },
    chuangxindanwei() {
      window.location.href =
        "https://" + window.location.host + "/common/award_export?type=2";
    },
    chuangxingeren() {
      window.location.href =
        "https://" + window.location.host + "/common/award_export?type=3";
    },
    cujingeren() {
      window.location.href =
        "https://" + window.location.host + "/common/award_export?type=5";
    },
    gongjiang() {
      window.location.href =
        "https://" + window.location.host + "/common/award_export?type=6";
    },
    chengguo() {
      window.location.href =
        "https://" + window.location.host + "/common/award_export?type=7";
    },
    heji() {
      console.log(
        "https://" + window.location.host + "/common/new_award_export?type=7"
      );
      window.location.href =
        "https://" + window.location.host + "/common/new_award_export?type=7";
    },
    statistics() {
      let params = {
        token: sessionStorage.getItem("Token1"),
      };
      statistics(params).then((res) => {
        var count = 0;
        var weitijiao = 0;
        var weitongguo = 0;
        var yitijiao = 0;
        var yitongguo = 0;
        var weishenhe = 0;
        res.data.data.forEach((item, index) => {
          item.indexs = parseInt(index) + 1;
          count += parseInt(item.count);
          weitijiao += parseInt(item.weitijiao);
          weitongguo += parseInt(item.weitongguo);
          yitijiao += parseInt(item.yitijiao);
          yitongguo += parseInt(item.yitongguo);
          weishenhe += parseInt(item.weishenhe) || 0;
        });
        res.data.data.push({
          count,
          weitijiao,
          weitongguo,
          yitijiao,
          yitongguo,
          award_name: "合计",
          indexs: "",
          weishenhe,
        });
        this.tableData = res.data.data;
      });
    },
  },
};
</script>

<style scoped>
.tongji {
  width: 100%;
  height: 100%;
  background-color: #fff;
}
.tables {
  width: 90%;
  margin: 0 auto;
}
.btn {
  display: flex;
  box-sizing: border-box;
  padding: 20px;
}
</style>